package exp2;

public class DiffArray {
    public static MyArrayList<Integer> diff(MyArrayList<Integer> A, MyArrayList<Integer> B) {
        MyArrayList<Integer> C = new MyArrayList<Integer>();
        Integer e;
        for (int i = 0; i < A.size(); i++)             //将A中不属于B的元素添加到C中
        {
            e = A.getElem(i);
            if (B.getNo(e) == -1)
                C.add(e);
        }
        return C;                        //返回C
    }

    public static void main(String[] args) {
        Integer x = 2, y = 5;
        Integer[] a = {1, 3, 2};
        MyArrayList<Integer> A = new MyArrayList<Integer>();
        A.createList(a);
        System.out.println("A: " + A.toString());

        Integer[] b = {5, 1, 4, 2};
        MyArrayList<Integer> B = new MyArrayList<Integer>();
        B.createList(b);
        System.out.println("B: " + B.toString());

        System.out.println("C=A-B");
        MyArrayList<Integer> C;
        C = diff(A, B);
        System.out.println("C: " + C.toString());
    }
}
